<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

    <title></title>

[#include "/admin/include/admin_static.htm"]
    <script type="text/javascript" src="${path}/resources/admin/js/jquery-1.7.1.min.js"></script>
    <script type="text/javascript" src="${path}/resources/admin/js/jquery.form.js"></script>
    <script charset="utf-8" src="${path}/resources/plug/kindeditor/kindeditor.js"></script>
    <script charset="utf-8" src="${path}/resources/plug/kindeditor/lang/zh_CN.js"></script>

</head>
<script type="text/javascript">


    $(function () {
        layui.use(['form', 'layer','upload','layedit'], function () {

            var form = layui.form(), $ = layui.jquery, layer = layui.layer,upload = layui.upload,layedit = layui.layedit;
            layui.upload({
                url: '/system/upload/submit.aspx'
                ,success: function(res,input){
                    console.log(input.id);
                    if (res["error"] == 0) {
                      $("#"+input.id+"_img").attr('src',res['url']);
                      $("input[name="+input.id+"]").val(res['url']);
                    }else
                    {
                        layer.msg(res["res"],{time:200}, function () {
                            location.reload();
                        });
                    }
                }
            });

            form.on('submit(saveForm)', function (data) {
                var index = layer.load();
                ajax({
                    url: "${path}/admin/rbac/saveSettings.aspx",
                    data: data.field,
                    success: function (result) {
                        layer.msg(result.content,{time:200}, function () {
                            location.reload();
                        });
                        layer.close(index);
                    },
                    complete: function () {
                        layer.close(index);
                    }
                });
                return false;
            });
        [@flash_message /]

        });
    });
</script>
<body>
<style>

    code {
        padding: 2px 4px;
        color: #d14;
        background-color: #f7f7f9;
        border: 1px solid #e1e1e8;
    }
</style>



<div class="main_admin_content">
    <form class="layui-form">

        <table class="layui-table">
            <colgroup>
                <col width="80">
                <col width="80">
                <col width="80">
                <col width="80">
                <col width="80">
            </colgroup>
            <thead>
            <tr>
                <th>
                    参数说明</th>
                <th>参数值</th>
                <th>变量名</th>
                <th>删除</th>
            </tr>
            </thead>
            <tbody>
            [#list parameters as parameter]
            <tr>
                <td>${parameter.name }</td>
                <td>
                    <input  type="hidden" name="code" value="${parameter.code }" >
                    [#if parameter.style==2 ]
                        <textarea class="layui-textarea" name="${parameter.code }" rows="4" cols="80">${parameter.text }</textarea>
                    [#elseif parameter.style==3 ]
                        <img src="${parameter.text }" id="${parameter.code }_img" >
                        <input type="file"  name="file" id="${parameter.code }"  class="layui-upload-file"/>
                        <input name="${parameter.code }" type="hidden" value="${parameter.text }">

                    [#else]
                        <input class="layui-input" type="text" name="${parameter.code }" value="${parameter.text }" class="long" />
                    [/#if]
                </td>
                <td class="code"><code>${parameter.code }</code></td>
                <td>
                    <input type="button" value="删除" onclick="window.location.href='${path}/admin/rbac/deleteSettings/${parameter.id}.aspx'"  class="layui-btn "/>

                </td>
            </tr>
            [/#list]

            </tbody>

        </table>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button lay-submit lay-filter="saveForm" class="layui-btn" style="width: 280px;margin-top:3px;">保存</button>
            </div>
        </div>


    </form>
</div>

</body>
</html>